using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.UIElements;

public class PostProcessingDara : MonoBehaviour
{
    
    [SerializeField] private PostFXSettings m_PostProcessingSetting;
    private VisualElement m_RootElement;
    
    private Toggle m_BloomToggle;
    private Toggle m_BlurToggle;
    //private Toggle m_ClearCoatToggle;
    //private Toggle m_MultiscatteringToggle;
    
    
    void Awake()
    {
        
        

    }

    
    // Start is called before the first frame update
    void Start()
    {
        m_RootElement = GetComponent<UIDocument>().rootVisualElement;
        m_BloomToggle = m_RootElement.Q<Toggle>("Bloom");
        m_BlurToggle = m_RootElement.Q<Toggle>("Blur");
        m_BloomToggle.SetValueWithoutNotify(m_PostProcessingSetting.Bloom.Enable);
        m_BlurToggle.SetValueWithoutNotify(m_PostProcessingSetting.Blur.Enable);
        m_BloomToggle.RegisterValueChangedCallback(OnBloomToggleChange);
        m_BlurToggle.RegisterValueChangedCallback(OnBlurToggleChange);
    }

    void OnEnable()
    {
        m_RootElement = GetComponent<UIDocument>().rootVisualElement;
        m_BloomToggle = m_RootElement.Q<Toggle>("Bloom");
        m_BlurToggle = m_RootElement.Q<Toggle>("Blur");
        m_BloomToggle.SetValueWithoutNotify(m_PostProcessingSetting.Bloom.Enable);
        m_BlurToggle.SetValueWithoutNotify(m_PostProcessingSetting.Blur.Enable);
        m_BloomToggle.RegisterValueChangedCallback(OnBloomToggleChange);
        m_BlurToggle.RegisterValueChangedCallback(OnBlurToggleChange);
    }
    private void OnBlurToggleChange(ChangeEvent<bool> evt)
    {
        m_PostProcessingSetting.Blur.Enable = evt.newValue;
    }

    private void OnBloomToggleChange(ChangeEvent<bool> evt)
    {
        m_PostProcessingSetting.Bloom.Enable = evt.newValue;
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
